<%-- 
    Document   : dangnhap
    Created on : Dec 15, 2013, 10:08:54 PM
    Author     : home
--%>

<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page isErrorPage="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<t:layout>
    <jsp:body>
        <c:if test="${param.error == 1}">
            <script language="JavaScript">
                alert('Đăng nhập thất bại!');
                setTimeout("top.location.href = '<c:url value="/DangNhap/" />'", 0);
            </script>
        </c:if>
        <c:if test="${param.error == 2}">
            <script language="JavaScript">
                alert('Bạn phải đăng nhập để mua sản phẩm!');
                setTimeout("top.location.href = '<c:url value="/DangNhap/" />'", 0);
            </script>
        </c:if>
        <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tbody>
                <tr>
                    <td class="bgtitle">
                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                            <tbody>
                                <tr>
                                    <td width="20">
                                        <img src="<c:url value="/resources/images/mui_ten.gif" />" >
                                    </td>
                                    <td valign="bottom" class="title">Đăng nhập</td>
                                    <td width="10" valign="bottom">&nbsp;</td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td valign="top">
                        <img src="<c:url value="/resources/images/space.gif" />" width="1" height="10">
                    </td>
                </tr>
                <tr>
                    <td valign="top">
                        <table width="100%" border="0" cellspacing="0" cellpadding="5">
                            <tbody>
                                <tr>
                                    <td style="border:1px #CCCCCC solid; padding:10px">
                                        <script language="JavaScript" type="text/javascript">
                                            function verifyloginForm(theForm)
                                            {
                                                with (theForm)
                                                {
                                                    if (email.value == "")
                                                    {
                                                        alert("Vui lòng nhập địa chỉ email!");
                                                        email.focus();
                                                        return false;
                                                    }
                                                    else
                                                    {
                                                        if (email.value.indexOf("@") < 0 || email.value.indexOf(".") < 0)
                                                        {
                                                            alert("Email không hợp lệ! Vui lòng nhập lại");
                                                            email.focus();
                                                            return false;
                                                        }
                                                    }
                                                    if (matKhau.value == "")
                                                    {
                                                        alert("Vui lòng nhập mật khẩu!");
                                                        matKhau.focus();
                                                        return false;
                                                    }
                                                    return true
                                                }
                                            }
                                        </script>
                                        <form:form method="post" action="XuLi" modelAttribute="nguoidung" style="margin:0; padding:0" onsubmit="return verifyloginForm(this)">
                                            <table width="40%" border="0" align="center" cellpadding="3" cellspacing="0" bordercolor="#CCCCCC" style="font-family: Tahoma; font-size: 10pt; border-collapse:collapse; padding:10px">
                                                <tbody>
                                                    <tr>
                                                        <td width="25%"><form:label path="email">Địa chỉ email </form:label></td>
                                                        <td width="70%"><form:input path="email" cssClass="box_input" size="24"/></td>
                                                    </tr>
                                                    <tr>
                                                        <td><form:label path="email">Mật khẩu </form:label></td>
                                                        <td><form:password path="matKhau" cssClass="box_input" size="24"/></td>
                                                    </tr>
                                                    <tr bgcolor="">
                                                        <td valign="top">&nbsp;</td>
                                                        <td>
                                                            <table border="0" cellspacing="0" cellpadding="0">
                                                                <tbody>
                                                                    <tr>
                                                                        <td>
                                                                            <input type="submit" name="button" id="button" value="Đăng nhập"></td>
                                                                        <td width="10">&nbsp;</td>
                                                                        <td>&nbsp;</td>
                                                                    </tr>
                                                                </tbody>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                    <tr bgcolor="">
                                                        <td valign="top">&nbsp;</td>
                                                        <td style="padding-top:10px;">
                                                            <a href="/resetpass">Quên mật khẩu ?</a>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </form:form>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </tbody>
        </table>
    </jsp:body>
</t:layout>